﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace DBService
{
	public partial class DlgProjectUser : System.Windows.Forms.Form
	{
		public DlgProjectUser(DbProject project, DbUser user)
		{
			this.mProject = project;
			this.mUser = user;
			this.InitializeComponent();
			this.cbxProject.Items.Add(project);
			this.cbxProject.SelectedIndex = 0;
			this.cbxType.SelectedIndex = 0;
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			try
			{
				DbProject dbProject = (DbProject)this.cbxProject.SelectedItem;
				this.mUser.SubmitToProject(dbProject.Id, (UserType)this.cbxType.SelectedIndex, BimServerDB.Default);
				DbUser.System.SendMessage("项目管理员", string.Concat(new string[]
				{
					"用户",
					this.mUser.Name,
					"申请加入项目",
					dbProject.Name,
					"，请审核。"
				}));
				MessageBox.Show("申请提交成功。");
				base.Close();
			}
			catch (Exception)
			{
				MessageBox.Show("请勿重复提交申请。");
			}
		}

		private void button2_Click(object sender, EventArgs e)
		{
		}

		private DbProject mProject;

		private DbUser mUser;
	}
}
